﻿using CPPEI.Coolzon.UI.XProperty;
using CPPEI.Coolzon.UI.XProperty.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.UI.DataPartLib.XProperty.Convertors
{
    public class XShapesConverter : IPropertyValueConverter
    {
        public object Convert(ConvertContext context, Metadata.ValueNode valueNode)
        {
            string str = valueNode.Attributes["Value"];
            if (!string.IsNullOrEmpty(str))
            {
                Visifire.Gauges.Shapes ret = (Visifire.Gauges.Shapes)Enum.Parse(typeof(Visifire.Gauges.Shapes), str);
                return ret;
            }
            return null;
        }

        public Metadata.ValueNode ConvertBack(ConvertContext context, object value)
        {
            Visifire.Gauges.Shapes placementTypes = (Visifire.Gauges.Shapes)value;
            Metadata.ValueNode valueNode = new Metadata.ValueNode("Shapes");
            valueNode.Attributes = new Dictionary<string, string>();
            valueNode.Attributes.Add("Value", placementTypes.ToString());
            return valueNode;
        }
    }
}
